package models;

import java.sql.Date;
import java.util.ArrayList;

public class Player {

	private int ID;
	private String login;
	private String accountname;
	private ArrayList<Item> items;
	private boolean banned;
	private Date dateOfBan;
	private Date dateOfRegistration;
	private RuneList runelist;
	private GemList gemlist;
	
	public Player(int id, String login, String accountname, boolean banned, Date dateofban, Date dateofregistration) {
		ID = id;
		this.login = login;
		this.accountname = accountname;
		this.items = new ArrayList<Item>();
		this.banned = banned;
		this.dateOfBan = dateofban;
		this.dateOfRegistration = dateofregistration;
		this.runelist = new RuneList();
		this.gemlist = new GemList();
	}

	public int getID() {
		return ID;
	}

	public void setID(int id) {
		ID = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getAccountname() {
		return accountname;
	}

	public void setAccountname(String accountname) {
		this.accountname = accountname;
	}

	public boolean isBanned() {
		return banned;
	}

	public void setBanned(boolean banned) {
		this.banned = banned;
	}

	public Date getDateOfBan() {
		return dateOfBan;
	}

	public void setDateOfBan(Date dateOfBan) {
		this.dateOfBan = dateOfBan;
	}

	public Date getDateOfRegistration() {
		return dateOfRegistration;
	}

	public void setDateOfRegistration(Date dateOfRegistration) {
		this.dateOfRegistration = dateOfRegistration;
	}

	public ArrayList<Item> getItems() {
		return items;
	}
	
	public void addItem(Item item) {
		this.items.add(item);
	}
	
	public void removeItem(Item item) {
		this.items.remove(item);
	}
	
	public void removeItem(int i) {
		this.items.remove(i);
	}
	
	public void clearItems() {
		this.items.clear();
	}

	public RuneList getRunelist() {
		return runelist;
	}

	public GemList getGemlist() {
		return gemlist;
	}

	public String itemsToString() {
		String temp = "----\n";
		if(items.isEmpty()){
			temp = temp + "No items!\n----\n";
		}
		else {
			for(Item i : items) {
				temp = temp + i.toString() + "----\n";
			}
		}
		return temp;
	}
	
	public String toString() {
		String temp = "Player: " + login + "\n";
		temp = temp + "  ID: " + ID + "\n";
		temp = temp + "  Account name: " + accountname + "\n";
		temp = temp + "  Date of registration: " + dateOfRegistration.toString() + "\n";
		if(banned) {
			temp = temp + "  Player is banned!\n";
			temp = temp + "  Ban date: " + dateOfBan + "\n";
		}
		return temp;
	}
	
}
